package com.hdaccp.beike
import org.apache.spark.SparkConf
import org.apache.spark.streaming.{Seconds, StreamingContext}
/**
  * Spark Steaming入门
  */
object Demo6 {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("beikeDemo6App").setMaster("local[2]")
    val ssc = new StreamingContext(conf, Seconds(5))
    val lines = ssc.socketTextStream("192.168.15.11", 6789)

    lines.flatMap(x=>x.split(" ")).map(y=>(y,1)).reduceByKey((_+_)).print()


    ssc.start()
    ssc.awaitTermination()
  }
}
